package com.example.sanchuang_demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.sanchuang_demo.domain.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Mapper
@Repository
public interface LoginMapper extends BaseMapper<User> {

    @Select("SELECT * FROM user WHERE userName = #{userName}")
    User getUser(String userName);

    @Select({
            "SELECT user.id,user.username,role.id,role.role_name,permission.id,permission.permission\n" +
                    "FROM user,role,permission\n" +
                    "WHERE user.username='username' AND user.role_id=role.id AND role.id=permission.role_id"
    })
    List<Map<String, Object>> getUserPower( String userName);
}